package demo.generate.Demo_ChangeMethod;

import com.sun.xml.internal.ws.org.objectweb.asm.ClassAdapter;
import com.sun.xml.internal.ws.org.objectweb.asm.ClassVisitor;
import com.sun.xml.internal.ws.org.objectweb.asm.MethodVisitor;

/**
 * Created by zhangyanfei on 2018/10/17.
 *
 * @author zhangyanfei
 * @date 2018/10/17
 */
public class AddSecurityCheckClassAdapter extends ClassAdapter {
    private String superName;

    public AddSecurityCheckClassAdapter(ClassVisitor cv) {
        super(cv);
    }

    @Override
    public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
        MethodVisitor mv = cv.visitMethod(access, name, desc, signature, exceptions);
        MethodVisitor mvWrapper = mv;
        if (mv != null) {
            if (name.equals("operation")) {
                mvWrapper = new SecurityCheckMethodAdpter(mv);
            }
        }
        return mvWrapper;
    }
}
